import { _decorator, IVec2 } from 'cc';
import { EntityManager } from '../../Base/EntityManager';
import { EntityTypeEnum } from '../../Common';
import { EntityStateEnum } from '../../Enum';
import { ExplosionStateMachine } from './ExplosionStateMachine';
const { ccclass } = _decorator;

@ccclass("ExplosionManager")
export class ExplosionManager extends EntityManager {

    public type: EntityTypeEnum;
    public id: number;
    init(type: EntityTypeEnum, id: number, { x, y }: IVec2) {
        this.type = type;
        this.id = id;

        this.fsm = this.node.getComponent(ExplosionStateMachine) || this.addComponent(ExplosionStateMachine);
        this.fsm.init(type)

        this.state = EntityStateEnum.Idle;
        this.node.setPosition(x, y);
    }
    reset() {
        this.fsm.reset();
        this.destroy();
    }
}